﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;

namespace Maticsoft.Web.Admin.Sys
{
    public partial class Siteconfig : PageBase
    {
        int ConfigId = 1;
        BLL.WebSiteConfig bll = new BLL.WebSiteConfig();
        protected void Page_Load(object sender, EventArgs e)
        {
            Check("Sys", "modify");

            if (!IsPostBack)
            {
                GetData();
            }
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Model.WebSiteConfig model = bll.GetModel(ConfigId);
            model.SiteName = txtTitle.Text.Trim();
            model.KeyWords = txtKeywords.Text.Trim();
            model.Description = txtDesc.Text.Trim();
            model.Copyright = txtCopyright.Text.Trim();
            model.Email = txtEmail.Text.Trim();
            model.Phone = txtPhone.Text.Trim();
            model.ext1 = txtExt1.Text.Trim();
            model.ext2 = txtExt2.Text.Trim();
            bll.Update(model);

            MessageBox.ShowAndRedirect(this, "修改成功", "Siteconfig.aspx");
        }

        private void GetData()
        {
            Model.WebSiteConfig model = bll.GetModel(ConfigId);
            txtTitle.Text = model.SiteName;
            txtKeywords.Text = model.KeyWords;
            txtDesc.Text = model.Description;
            txtCopyright.Text = model.Copyright;
            txtEmail.Text = model.Email;
            txtPhone.Text = model.Phone;
            txtExt1.Text = model.ext1;
            txtExt2.Text = model.ext2;
        }
    }
}